{% extends 'layout.html' %}
{% block title %}
    <title>用户列表</title>
{% endblock %}


{% block content %}
    <div style="margin-bottom: 15px">
        <a href="{% url 'user_add' %}">
            <button type="button" class="btn btn-primary">新增</button>
        </a>
    </div>
    <div class="panel panel-default">
        <div class="panel-heading">用户列表</div>
        <div class="panel-body">
            <table class="table  table-striped">
                <tr>
                    <th>序号</th>
                    <th>用户名</th>
                    <th>年龄</th>
                    <th>性别</th>
                    <th>部门</th>
                    <th>操作</th>
                </tr>
                {% for user in users %}
                    <tr>
                        <td>{{ forloop.counter }}</td>
                        <td>{{ user.username }}</td>
                        <td>{{ user.age }}</td>
                        <td>{{ user.get_gender_display }}</td>
                        <td>{{ user.dept.name }}</td>
                        <td>
                            <a href="{% url 'user_edit' user.id %}">
                                <button class="btn btn-primary">编辑</button>
                            </a>
                            <a href="{% url 'user_delete' user.id %}">
                                <button class="btn btn-danger">删除</button>
                            </a>
                        </td>
                    </tr>
                {% endfor %}

            </table>
        </div>
    </div>
{% endblock %}